package cn.edu.ctgu;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.zone.ZoneRules;
import java.util.Set;

public class TestDate {
    public static void main(String[] args) {
        LocalDate currentDate = LocalDate.of(2025,1,30);
        System.out.println(currentDate);
        LocalDate nextDate = currentDate.plusMonths(1).plusMonths(2);
        System.out.println(nextDate);
        LocalDate nextDate2 = currentDate.plusMonths(2).plusMonths(1);
        System.out.println(nextDate2);

        LocalDateTime dateTime = LocalDateTime.of(2025,3,9,2,0);
        isDayLightSaving(dateTime);

        LocalDateTime dateTime1 = LocalDateTime.of(2025,3,9,1,59);
        isDayLightSaving(dateTime1);
        //        Set<String> allZoneIds = ZoneId.getAvailableZoneIds();
//        allZoneIds.forEach(System.out::println);


    }

    private static void isDayLightSaving(LocalDateTime dateTime) {
        ZoneId zoneId = ZoneId.of("America/New_York");
        ZonedDateTime zonedDateTime = ZonedDateTime.of(dateTime, zoneId);
        ZoneRules zoneRules = zoneId.getRules();

        if (zoneRules.isDaylightSavings(zonedDateTime.toInstant())) {
            System.out.println(dateTime+":是夏令时");
        } else {
            System.out.println(dateTime+":不是夏令时");
        }
    }
}
